{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python时间处理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\" style=\"margin-top: 1em;\"><ul class=\"toc-item\"><li><span><a href=\"#获取并格式化时间\" data-toc-modified-id=\"获取并格式化时间-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>获取并格式化时间</a></span></li><li><span><a href=\"#转换时间格式\" data-toc-modified-id=\"转换时间格式-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>转换时间格式</a></span></li><li><span><a href=\"#计算两个时间间隔\" data-toc-modified-id=\"计算两个时间间隔-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>计算两个时间间隔</a></span><ul class=\"toc-item\"><li><span><a href=\"#计算2016-12-1和1990-1-1中间天数和秒数\" data-toc-modified-id=\"计算2016-12-1和1990-1-1中间天数和秒数-3.1\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>计算2016-12-1和1990-1-1中间天数和秒数</a></span></li><li><span><a href=\"#计算两个时间戳间隔时间\" data-toc-modified-id=\"计算两个时间戳间隔时间-3.2\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>计算两个时间戳间隔时间</a></span></li></ul></li><li><span><a href=\"#获取前N天，或者后N天时间\" data-toc-modified-id=\"获取前N天，或者后N天时间-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>获取前N天，或者后N天时间</a></span></li><li><span><a href=\"#时间戳相关计算\" data-toc-modified-id=\"时间戳相关计算-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>时间戳相关计算</a></span></li><li><span><a href=\"#各种数据类型间转换\" data-toc-modified-id=\"各种数据类型间转换-6\"><span class=\"toc-item-num\">6&nbsp;&nbsp;</span>各种数据类型间转换</a></span><ul class=\"toc-item\"><li><span><a href=\"#str-&gt;-datetime.datetime\" data-toc-modified-id=\"str->-datetime.datetime-6.1\"><span class=\"toc-item-num\">6.1&nbsp;&nbsp;</span>str &gt; datetime.datetime</a></span></li><li><span><a href=\"#str-&gt;-时间元组\" data-toc-modified-id=\"str->-时间元组-6.2\"><span class=\"toc-item-num\">6.2&nbsp;&nbsp;</span>str &gt; 时间元组</a></span></li><li><span><a href=\"#时间戳-&gt;-datetime.datetime-或-datetime.date\" data-toc-modified-id=\"时间戳->-datetime.datetime-或-datetime.date-6.3\"><span class=\"toc-item-num\">6.3&nbsp;&nbsp;</span>时间戳 &gt; datetime.datetime 或 datetime.date</a></span></li><li><span><a href=\"#时间戳-&gt;-时间元组\" data-toc-modified-id=\"时间戳->-时间元组-6.4\"><span class=\"toc-item-num\">6.4&nbsp;&nbsp;</span>时间戳 &gt; 时间元组</a></span></li><li><span><a href=\"#时间元组-&gt;-时间戳\" data-toc-modified-id=\"时间元组->-时间戳-6.5\"><span class=\"toc-item-num\">6.5&nbsp;&nbsp;</span>时间元组 &gt; 时间戳</a></span></li><li><span><a href=\"#时间元组-&gt;-datetime.datetime-或-datetime.date\" data-toc-modified-id=\"时间元组->-datetime.datetime-或-datetime.date-6.6\"><span class=\"toc-item-num\">6.6&nbsp;&nbsp;</span>时间元组 &gt; datetime.datetime 或 datetime.date</a></span></li><li><span><a href=\"#时间戳-&gt;-时间元组\" data-toc-modified-id=\"时间戳->-时间元组-6.7\"><span class=\"toc-item-num\">6.7&nbsp;&nbsp;</span>时间戳 &gt; 时间元组</a></span></li><li><span><a href=\"#datetime.datetime-或-datetime.date-&gt;-weekday\" data-toc-modified-id=\"datetime.datetime-或-datetime.date->-weekday-6.8\"><span class=\"toc-item-num\">6.8&nbsp;&nbsp;</span>datetime.datetime 或 datetime.date &gt; weekday</a></span></li></ul></li><li><span><a href=\"#格式化与反格式化控制字符对照表\" data-toc-modified-id=\"格式化与反格式化控制字符对照表-7\"><span class=\"toc-item-num\">7&nbsp;&nbsp;</span>格式化与反格式化控制字符对照表</a></span></li></ul></div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-29T07:59:06.507370Z",
     "start_time": "2018-01-29T07:59:06.504164Z"
    }
   },
   "outputs": [],
   "source": [
    "import time\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 获取并格式化时间 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用time模块获取当前时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T06:49:13.153341Z",
     "start_time": "2018-01-24T06:49:13.147194Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-01-24 14:49:13\n"
     ]
    }
   ],
   "source": [
    "print time.strftime('%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用datetime模块获取当前日期和当前时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T06:50:19.338243Z",
     "start_time": "2018-01-24T06:50:19.334301Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-01-24\n"
     ]
    }
   ],
   "source": [
    "today = datetime.date.today()\n",
    "print today.strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T06:54:31.510250Z",
     "start_time": "2018-01-24T06:54:31.505948Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-01-24 14:54:31\n"
     ]
    }
   ],
   "source": [
    "now = datetime.datetime.now()\n",
    "print now.strftime('%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T06:55:13.550803Z",
     "start_time": "2018-01-24T06:55:13.536595Z"
    }
   },
   "source": [
    "attention: time大小写表示方法：%y-%m-%d %H:%M:%S<br>\n",
    "        datetime大小写表示方法：%Y-%m-%d %H:%M:%S"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 转换时间格式"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "例如我们拿到了一个时间字符串 161201 16:14:22 需要将其转换成其他格式。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:23:51.732779Z",
     "start_time": "2018-01-24T07:23:51.729469Z"
    }
   },
   "outputs": [],
   "source": [
    "struct_time = time.strptime('161201 16:14:22','%y%m%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "struct_time 为一个时间元组对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T06:58:23.644101Z",
     "start_time": "2018-01-24T06:58:23.640112Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16-12-01 16:14;22\n"
     ]
    }
   ],
   "source": [
    "print time.strftime('%y-%m-%d %H:%M;%S',struct_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:01:09.158045Z",
     "start_time": "2018-01-24T07:01:09.153394Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16-12-01 16:14;22\n"
     ]
    }
   ],
   "source": [
    "dt = datetime.datetime.strptime('161201 16:14:22','%y%m%d %H:%M:%S')\n",
    "print dt.strftime('%y-%m-%d %H:%M;%S')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 计算两个时间间隔"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:01:55.901980Z",
     "start_time": "2018-01-24T07:01:55.882396Z"
    }
   },
   "source": [
    "计算时间间隔使用datetime模块比较方便。 <br>\n",
    "datetime.date为日期对象，最小精度为天。 <br>\n",
    "datetime.datetime为日期时间对象，最小精度为秒（毫秒也可以） <br>\n",
    "实际使用中按需选择。<br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 计算2016-12-1和1990-1-1中间天数和秒数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:16:57.847897Z",
     "start_time": "2018-01-24T07:16:57.844179Z"
    }
   },
   "outputs": [],
   "source": [
    "dt = datetime.date(2016,12,1) - datetime.date(1990,1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:17:12.930201Z",
     "start_time": "2018-01-24T07:17:12.924375Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9831"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:25:56.056344Z",
     "start_time": "2018-01-24T07:25:56.043772Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9831\n",
      "849398400.0\n"
     ]
    }
   ],
   "source": [
    "# 将字符串转换为datetime.date对象\n",
    "\n",
    "dt_a = datetime.datetime.strptime('2016-12-1','%Y-%m-%d') # datetime.date 无 strptime 方法\n",
    "dt_b = datetime.datetime.strptime('1990-1-1','%Y-%m-%d') # 虽然格式化时间的时候%m为两位数月份,但是反格式化时一位月份也可工作\n",
    "dt = dt_a - dt_b\n",
    "print dt.days\n",
    "print dt.total_seconds()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 计算两个时间戳间隔时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:29:23.894671Z",
     "start_time": "2018-01-24T07:29:23.888940Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 110000.0\n"
     ]
    }
   ],
   "source": [
    "timestamp_a, timestamp_b = 1480582517, 1480472517\n",
    "dt = datetime.datetime.fromtimestamp(timestamp_a) - datetime.datetime.fromtimestamp(timestamp_b)\n",
    "print dt.days,dt.total_seconds()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 获取前N天，或者后N天时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:31:42.889528Z",
     "start_time": "2018-01-24T07:31:42.879869Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-01-23 15:31:42.883862\n",
      "2018-01-25 15:31:42.883862\n"
     ]
    }
   ],
   "source": [
    "now = datetime.datetime.now()\n",
    "before_time = now - datetime.timedelta(days=1)\n",
    "after_time = now + datetime.timedelta(days=1)\n",
    "print before_time\n",
    "print after_time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 时间戳相关计算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:35:46.426946Z",
     "start_time": "2018-01-24T07:35:46.420381Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "ts = int(time.time())\n",
    "print (ts / 86400 +4) % 7  # 获取时间戳对应的星期 0 周日 - 6 周六"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:36:33.695046Z",
     "start_time": "2018-01-24T07:36:33.688336Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "timestamp_a, timestamp_b = 1480582517, 1480472517\n",
    "ts = timestamp_a - timestamp_b\n",
    "print ts / 86400 # 获取两个时间戳相隔天数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:36:55.751447Z",
     "start_time": "2018-01-24T07:36:55.746519Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1516752000\n"
     ]
    }
   ],
   "source": [
    "# 获取当天00:00:00的时间戳\n",
    "ts = int(time.time())\n",
    "print ts / 86400 * 86400"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:37:13.073331Z",
     "start_time": "2018-01-24T07:37:13.064439Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1516838399\n"
     ]
    }
   ],
   "source": [
    "# 获取当天23:59:59的时间戳\n",
    "ts = int(time.time())\n",
    "print ts / 86400 * 86400 + 86400 - 1\n",
    "# Out: 1480636799"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 各种数据类型间转换"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### str > datetime.datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:38:09.625331Z",
     "start_time": "2018-01-24T07:38:09.616280Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2016, 12, 1, 16, 14, 22)"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.datetime.strptime('161201 16:14:22', '%y%m%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### str > 时间元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:39:04.964558Z",
     "start_time": "2018-01-24T07:39:04.959130Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2016, tm_mon=12, tm_mday=1, tm_hour=16, tm_min=14, tm_sec=22, tm_wday=3, tm_yday=336, tm_isdst=-1)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = datetime.datetime.strptime('161201 16:14:22', '%y%m%d %H:%M:%S')\n",
    "dt.timetuple()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "or"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:39:25.003025Z",
     "start_time": "2018-01-24T07:39:24.998000Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2016, tm_mon=12, tm_mday=1, tm_hour=16, tm_min=14, tm_sec=22, tm_wday=3, tm_yday=336, tm_isdst=-1)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "struct_time = time.strptime('161201 16:14:22', '%y%m%d %H:%M:%S')\n",
    "struct_time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 时间戳 > datetime.datetime 或 datetime.date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:41:55.192521Z",
     "start_time": "2018-01-24T07:41:55.177930Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2018, 1, 24, 15, 41, 55)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shijianchuo = int(time.time())\n",
    "datetime.datetime.fromtimestamp(shijianchuo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:42:15.154499Z",
     "start_time": "2018-01-24T07:42:15.148225Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2018, 1, 24)"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.fromtimestamp(shijianchuo)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 时间戳 > 时间元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:44:19.743318Z",
     "start_time": "2018-01-24T07:44:19.737988Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2018, tm_mon=1, tm_mday=24, tm_hour=7, tm_min=41, tm_sec=55, tm_wday=2, tm_yday=24, tm_isdst=0)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time_tuple = time.gmtime(shijianchuo)\n",
    "time_tuple"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 时间元组 > 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:44:27.967176Z",
     "start_time": "2018-01-24T07:44:27.962338Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1516750915.0"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.mktime(time_tuple)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:44:36.798511Z",
     "start_time": "2018-01-24T07:44:36.794059Z"
    }
   },
   "source": [
    "### 时间元组 > datetime.datetime 或 datetime.date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:45:37.949496Z",
     "start_time": "2018-01-24T07:45:37.941157Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2018, 1, 24, 7, 41, 55)"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.datetime.fromtimestamp(time.mktime(time_tuple))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:46:14.232698Z",
     "start_time": "2018-01-24T07:46:14.227269Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2018, 1, 24)"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.fromtimestamp(time.mktime(time_tuple))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 时间戳 > 时间元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:46:53.199608Z",
     "start_time": "2018-01-24T07:46:53.195016Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2018, tm_mon=1, tm_mday=24, tm_hour=7, tm_min=41, tm_sec=55, tm_wday=2, tm_yday=24, tm_isdst=0)"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime(shijianchuo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:47:54.706366Z",
     "start_time": "2018-01-24T07:47:54.699376Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2018, tm_mon=1, tm_mday=24, tm_hour=15, tm_min=41, tm_sec=55, tm_wday=2, tm_yday=24, tm_isdst=-1)"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = datetime.datetime.fromtimestamp(shijianchuo)\n",
    "dt.timetuple()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### datetime.datetime 或 datetime.date > weekday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-29T07:59:22.810281Z",
     "start_time": "2018-01-29T07:59:22.805167Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date(2018, 1, 29).isoweekday()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "or"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-29T08:00:17.041848Z",
     "start_time": "2018-01-29T08:00:17.036211Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.isoweekday(datetime.date(2018, 1, 29))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 格式化与反格式化控制字符对照表"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table data-anchor-id=\"gu6a\" class=\"\"><thead><tr><th style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: bottom; border-top-width: 0px; font-weight: 700; border-left: 1px solid rgb(221, 221, 221); border-top-left-radius: 4px;\" width=\"46\"><span style=\"font-size: 14px;\">字符</span></th><th style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: bottom; border-top-width: 0px; font-weight: 700; border-left: 1px solid rgb(221, 221, 221);\" width=\"115\"><span style=\"font-size: 14px;\">含义</span></th><th style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: bottom; border-top-width: 0px; font-weight: 700; border-left: 1px solid rgb(221, 221, 221); border-top-right-radius: 4px;\" width=\"298\"><span style=\"font-size: 14px;\">例子</span></th></tr></thead><tbody><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%a</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的星期缩写</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">Sun,Mon...Sat(en_US);So,Mo...Sa(de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%A</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的星期全拼</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">Sunday,Monday...Saturday(en_US);Sonntag,Montag...Samstag(de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%w</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">星期的数字表示0表示周日,6表示周六</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">0,1...6</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%d</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">日,当月第几天,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">01,02...31</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%b</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的月份缩写</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">Jan,Feb...Dec(en_US);Jan,Feb...Dez(de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%B</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的月份全拼</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">January, February,...,December(en_US);Januar,Februar...Dezember(de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%m</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">月份的数字表示,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">01,02...12</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%y</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">年份表示,不带世纪,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...99</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%Y</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">年份表示</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">1970,1971...2016</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%H</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">小时 0-23</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...23</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%I</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">小时 01-12</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">01,02...12</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%p</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的上午下午表示</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">AM,PM(en_US);am,pm(de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%M</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">分钟,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...59</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%S</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">秒,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...59</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%f</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">微妙,六位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">000000,000001...999999</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%z</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">时区偏移量,表示为+HHMM或-HHMM或空</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">(空),+0000,-0400,+0800</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%Z</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">时区名字</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">(空),UTC, EST, CST</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%j</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">日,当年第几天,三位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">001,002...366</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%U</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">周,在年第几周,周日为一周的第一天,新年第一个星期日第0周,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...53</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%W</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">周,在年第几周,周一为一周的第一天,新年第一个星期一第0周,两位数</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">00,01...53</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%c</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的时间日期表示</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">Tue Aug 16 21:30:00 1988 (en_US);Di 16 Aug 21:30:00 1988 (de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"24\"><span style=\"font-size: 14px;\">%x</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的日期表示</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"294\"><span style=\"font-size: 14px;\">08/16/88 (None);08/16/1988 (en_US);16.08.1988 (de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"24\"><span style=\"font-size: 14px;\">%X</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"111\"><span style=\"font-size: 14px;\">当地格式的时间表示</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); background-color: rgba(102, 128, 153, 0.047);\" width=\"294\"><span style=\"font-size: 14px;\">21:30:00 (en_US);21:30:00 (de_DE)</span></td></tr><tr><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); border-bottom-left-radius: 4px;\" width=\"24\"><span style=\"font-size: 14px;\">%%</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);\" width=\"111\"><span style=\"font-size: 14px;\">%字符</span></td><td style=\"padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221); border-bottom-right-radius: 4px; word-break: break-all;\" width=\"294\"><span style=\"font-size: 14px;\">%</span></td></tr></tbody></table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-01-24T07:50:20.580219Z",
     "start_time": "2018-01-24T07:50:20.572605Z"
    }
   },
   "source": [
    "来源：https://mp.weixin.qq.com/s?__biz=MzAxMjUyNDQ5OA==&mid=2653552307&idx=1&sn=b82b29ed3d2f591590b419867144b308&chksm=806dd00eb71a591872896feb4e9f2bd9dd5c51d83c88ee902078acaaae008cc009b029e6053d&mpshare=1&scene=23&srcid=1215hgVYlp4Yy3lrM9xPQjM0#rd"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  },
  "nbTranslate": {
   "displayLangs": [
    "*"
   ],
   "hotkey": "alt-t",
   "langInMainMenu": true,
   "sourceLang": "en",
   "targetLang": "fr",
   "useGoogleTranslate": true
  },
  "toc": {
   "nav_menu": {
    "height": "323px",
    "width": "296px"
   },
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": true,
   "toc_cell": true,
   "toc_position": {
    "height": "578px",
    "left": "0px",
    "right": "994.64px",
    "top": "0px",
    "width": "234px"
   },
   "toc_section_display": "block",
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
